using System;
using System.Collections;
using System.Collections.Generic;
using JK.EventRouter.Eventing;

namespace JK.EventRouter
{
    public class SubscriberMap : IDisposable
    {
        Dictionary<object, object> _actionMap = new Dictionary<object, object>();

        public void Add<T>(object subscriber, IAction<T> action)
        {
            _actionMap.Add(subscriber, action);
        }

        public void Remove(object subscriber)
        {
            if(_actionMap.ContainsKey(subscriber))
            {
                _actionMap.Remove(subscriber);
            }
        }

        public IEnumerable GetActions<T>()
        {
            return _actionMap.Values;
            
        }

        public void Dispose()
        {
            _actionMap.Clear();
        }
    }
}